package com.atung.merchant.result;

/**
 * @author Administrator
 */

public enum CommonResultCode   {
    SUCCESS(0, "操作成功"),

    LOGIN_ERR_USER_NAME_ISNULL(1400,"用户名不存在"),
    LOGIN_ERR_USER_PWD_ISNULL(1400,"密码错误"),
    UNAUTHORIZED(1401, "非法访问"),
    NOT_PERMISSION(1403, "没有权限"),
    NOT_FOUND(1404, "你请求的路径不存在"),
    REQUEST_FREQUENTLY(1405, "你请求过于[频繁]"),

    GIT_TOKEN_EXPIRE(2401, "git token失效"),
    WARN(10000, "请尝试刷新"),
    FAIL(50000, "系统繁忙，请稍后再试"),
    SQL_ERROR(50010, "请勿输入特殊字符或表情符号");

    private final int code;
    private final String message;

    private CommonResultCode(final int code, final String message) {
        this.code = code;
        this.message = message;
    }

    public static CommonResultCode getApiCode(int code) {
        CommonResultCode[] ecs = values();
        CommonResultCode[] var2 = ecs;
        int var3 = ecs.length;

        for(int var4 = 0; var4 < var3; ++var4) {
            CommonResultCode ec = var2[var4];
            if (ec.getCode() == code) {
                return ec;
            }
        }

        return null;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public static boolean isWarn(int code) {
        return code >= 10000 && code < 49999;
    }

    public static boolean isFail(int code) {
        return code >= 50000 && code < 99999;
    }
}